﻿using Microsoft.Owin;
using Owin;
using System.Web.Http;
using System.Net.Http.Formatting;
using Swashbuckle.Application;

[assembly: OwinStartup(typeof(ConsoleApplication1.Startup))]

namespace ConsoleApplication1
{
    public class Startup
    {
 
            public void Configuration(IAppBuilder appBuilder)
            {
                //创建Web API 的配置
                var config = new HttpConfiguration();
                //启动标记路由
                config.MapHttpAttributeRoutes();

                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{action}/{id}",//{action}目的是为了一个Controller能有多个Get Post方法
                    defaults: new { id = RouteParameter.Optional }
                );
                ////配置swagger　
                //config

                config
                    .EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
                    .EnableSwaggerUi();
                //清除xml格式，使用json格式
                config.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
                config.Formatters.Add(new JsonMediaTypeFormatter());

                //将路有配置附加到appBuilder
                appBuilder.UseWebApi(config);
            }
        }

}
